<template>
  <div class="line-box">
    <div class="title">
      <p>未来7天游客量趋势图</p>
      <p class="bg" />
    </div>
    <div ref="charts" class="echarts-box" />
  </div>
</template>

<script setup lang="ts" name="Line">
import { onMounted, ref } from 'vue';
import * as echarts from 'echarts';

let charts = ref();

onMounted(() => {
  let mycharts = echarts.init(charts.value);
  let option = {
    title: {
      text: '(访问量)',
      textStyle: {
        color: '#3589CF',
        fontSize: 12,
      },
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
      splitLine: {
        show: false,
      },
      axisLabel: {
        color: '#3589CF',
      },
    },
    yAxis: {
      splitLine: {
        show: false,
      },
      axisLine: {
        show: true,
      },
      axisTick: {
        show: true,
      },
      axisLabel: {
        color: '#3589CF',
      },
    },
    //调整图形图标的位置
    grid: {
      left: 45,
      top: 30,
      right: 20,
      bottom: 20,
    },
    series: [
      {
        type: 'line',
        data: [120, 1240, 66, 2299, 321, 890, 1200],
        smooth: true,
        lineStyle: {
          color: '#FF8100',
        },
        areaStyle: {
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: '#FF9400', // 0% 处的颜色
              },
              {
                offset: 1,
                color: '#FBB50101', // 100% 处的颜色
              },
            ],
            global: false, // 缺省为 false
          },
        },
      },
    ],
  };
  mycharts.setOption(option);
});
</script>

<style lang="less" scoped>
.line-box {
  background: url('@/assets/images/screen/dataScreen-main-cb.png') no-repeat;
  background-size: 100% 100%;
  .title {
    color: white;
    font-size: 20px;
    .bg {
      width: 68px;
      height: 7px;
      background: url('@/assets/images/screen/dataScreen-title.png') no-repeat;
      background-size: 100% 100%;
      margin-top: 10px;
    }
  }
  .echarts-box {
    margin-top: 20px;
    height: calc(100% - 60px);
  }
}
</style>
